/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package au.edu.swin.unilearn.universitystaff;

import au.edu.swin.unilearn.tutorialGroup.TutorialGroupEntity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author DidierLeung
 */
@Entity
@NamedQueries({
@NamedQuery(name = "findAllUniversityStaffs", query = "SELECT use FROM UniversityStaffEntity use")
})
@Table(name = "UNIVERSITYSTAFF")
public class UniversityStaffEntity implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @Column
    private String sims_id;
    @Column
    private String staff_name;
    @Column
    private String sims_password;
    @Column
    private String status;
    @OneToMany(mappedBy = "universityStaffEntity", cascade = CascadeType.ALL)
    private List<TutorialGroupEntity> tutorialGroupEntityCollection;

    public UniversityStaffEntity()
    {
    }

    public UniversityStaffEntity(String id, String name, String password,
            String status)
    {
        this();
        this.setSims_id(id);
        this.setStaff_name(name);
        this.setSims_password(password);
        this.setStatus(status);
    }

    public String getSims_id()
    {
        return sims_id;
    }

    public void setSims_id(String sims_id)
    {
        this.sims_id = sims_id;
    }

    public String getStaff_name()
    {
        return staff_name;
    }

    public void setStaff_name(String staff_name)
    {
        this.staff_name = staff_name;
    }

    public String getSims_password()
    {
        return sims_password;
    }

    public void setSims_password(String sims_password)
    {
        this.sims_password = sims_password;
    }

    public UniversityStaff getUniversityStaffObject()
    {
        return new UniversityStaff(sims_id, staff_name, sims_password, status);
    }

    public void setUniversityStaffEntityData(UniversityStaff us)
    {
        setSims_id(us.getId());
        setStaff_name(us.getName());
        setSims_password(us.getPassword());
    }

    public List<TutorialGroupEntity> getTutorialGroupEntityCollection()
    {
        return tutorialGroupEntityCollection;
    }

    public void setTutorialGroupEntityCollection(List<TutorialGroupEntity> tutorialGroupEntityCollection)
    {
        this.tutorialGroupEntityCollection = tutorialGroupEntityCollection;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }
    
    @Override
    public int hashCode()
    {
        return sims_id.hashCode();
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UniversityStaffEntity))
        {
            return false;
        }
        UniversityStaffEntity other = (UniversityStaffEntity) object;
        if ((this.getSims_id() == null && other.getSims_id() != null) ||
                (this.getSims_id() != null && !this.sims_id.equals(other.sims_id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "au.edu.swin.universitystaff.UniversityStaffEntity[id=" + getSims_id() + "]";
    }
}
